package jdbc;

import java.sql.*;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/18
 * @VERSION 1.0
 * @DESC
 */
public class JDBCUtil {
    private String URL="jdbc:mysql://47.98.99.88:3306/app";
    private String DRIVER="com.mysql.cj.jdbc.Driver";
    private String USERNAME="practice";
    private String PASSWORD="123456";
    Statement getStatement() throws ClassNotFoundException, SQLException {
        Connection connection;
        Statement statement;
        Class.forName(DRIVER);
        connection = DriverManager.getConnection(URL,USERNAME,PASSWORD);
        statement=connection.createStatement();
        return statement;
    }

    ResultSet query(String sql) throws SQLException, ClassNotFoundException {
        return getStatement().executeQuery(sql);
    }



    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        new JDBCUtil().getStatement();
    }



}
